import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.xianzi = pygame.image.load("../资源/图片/仙子.jpg").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.door_iron = pygame.image.load("../资源/图片/铁门.png").convert_alpha()
        self.big_coin = pygame.image.load("../资源/图片/大金币.png").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.ling_warrior = pygame.image.load("../资源/图片/灵武士.png").convert_alpha()

        self.hero_pos = (5, 1)
        self.down_pos = (5, 0)
        self.up_pos_left = (0, 5)
        self.up_pos_right = (10, 5)
        self.up_pos_down = (5, 10)
        self.variable_pos = {
            (6, 2): (self.xianzi, '仙子'),
            (5, 4): (self.big_coin, '大金币'),
            (5, 6): (self.big_coin, '大金币'),
            (4, 5): (self.big_coin, '大金币'),
            (6, 5): (self.big_coin, '大金币'),
            (5, 9): (self.hp_blue, '蓝药'),
            (4, 9): (self.hp_blue, '蓝药'),
            (6, 9): (self.hp_blue, '蓝药'),
            (4, 10): (self.hp_blue, '蓝药'),
            (6, 10): (self.hp_blue, '蓝药'),
            (0, 4): (self.gem_red, '红宝石'),
            (0, 6): (self.gem_red, '红宝石'),
            (1, 4): (self.gem_red, '红宝石'),
            (1, 5): (self.gem_red, '红宝石'),
            (1, 6): (self.gem_red, '红宝石'),
            (10, 4): (self.gem_blue, '蓝宝石'),
            (10, 6): (self.gem_blue, '蓝宝石'),
            (9, 4): (self.gem_blue, '蓝宝石'),
            (9, 5): (self.gem_blue, '蓝宝石'),
            (9, 6): (self.gem_blue, '蓝宝石'),
            (5, 3): (self.door_red, '红门'),
            (5, 7): (self.door_red, '红门'),
            (3, 5): (self.door_red, '红门'),
            (7, 5): (self.door_red, '红门'),
            (0, 3): (self.door_iron, '墙'),
            (1, 3): (self.door_iron, '墙'),
            (2, 3): (self.door_iron, '墙'),
            (2, 4): (self.door_iron, '墙'),
            (2, 6): (self.door_iron, '墙'),
            (2, 7): (self.door_iron, '墙'),
            (1, 7): (self.door_iron, '墙'),
            (0, 7): (self.door_iron, '墙'),
            (10, 3): (self.door_iron, '墙'),
            (9, 3): (self.door_iron, '墙'),
            (8, 3): (self.door_iron, '墙'),
            (8, 4): (self.door_iron, '墙'),
            (8, 6): (self.door_iron, '墙'),
            (8, 7): (self.door_iron, '墙'),
            (9, 7): (self.door_iron, '墙'),
            (10, 7): (self.door_iron, '墙'),
            (3, 10): (self.door_iron, '墙'),
            (3, 9): (self.door_iron, '墙'),
            (3, 8): (self.door_iron, '墙'),
            (4, 8): (self.door_iron, '墙'),
            (6, 8): (self.door_iron, '墙'),
            (7, 8): (self.door_iron, '墙'),
            (7, 9): (self.door_iron, '墙'),
            (7, 10): (self.door_iron, '墙'),
            (2, 5): (self.ling_warrior, '灵武士_sss'),
            (8, 5): (self.ling_warrior, '灵武士_sss'),
            (5, 8): (self.ling_warrior, '灵武士_sss'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos_left[0], self.up_pos_left[1])
        self.dic[self.up_pos_left] = '上23楼左'
        self.draw(self.upstairs, self.up_pos_right[0], self.up_pos_right[1])
        self.dic[self.up_pos_right] = '上23楼右'
        self.draw(self.upstairs, self.up_pos_down[0], self.up_pos_down[1])
        self.dic[self.up_pos_down] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(11):
            if i != 5:
                for j in [0, 1, 2]:
                    if (i, j) != (4, 2) and (i, j) != (6, 2):
                        self.draw(self.wall, i, j)
                        self.dic[(i, j)] = '墙'
        for i in range(3):
            for j in range(3):
                self.draw(self.wall, i, j + 8)
                self.dic[(i, j + 8)] = '墙'
                self.draw(self.wall, 10 - i, j + 8)
                self.dic[(10 - i, j + 8)] = '墙'
        for i in [3, 4]:
            for j in [3, 4]:
                self.draw(self.wall, i, j)
                self.dic[(i, j)] = '墙'
                self.draw(self.wall, 10 - i, 10 - j)
                self.dic[(10 - i, 10 - j)] = '墙'
                self.draw(self.wall, i, 10 - j)
                self.dic[(i, 10 - j)] = '墙'
                self.draw(self.wall, 10 - i, j)
                self.dic[(10 - i, j)] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
